package com.agenda.controller;

import com.agenda.concorrencia.Semaforo;

public class VideoController {

	private static final int MAXIMO_SALAS = 1;

	private static VideoController INSTANCE;

	public static VideoController getINSTANCE() {
		if (INSTANCE == null)
			INSTANCE = new VideoController();

		return INSTANCE;
	}

	private Semaforo semaforo;

	private boolean emUso;

	private VideoController() {
		semaforo = new Semaforo();
	}

	public void liberarSala() {
		semaforo.DOWN();

		emUso = false;

		semaforo.UP();
	}

	public Boolean reservarSalaVideo() {
		Boolean reservou = new Boolean(false);
		semaforo.DOWN();

		if (!emUso) {

			emUso = true;

			reservou = Boolean.TRUE;
		}
		semaforo.UP();

		return reservou;
	}

}
